#pragma once
#include "MemoryOperator.h"
#include <list>
/*
	生成响应头
*/
class HTTPResponserHeader
{
public:
	HTTPResponserHeader();
	
	virtual ~HTTPResponserHeader();

	// 设置响应码 返回之前的相应码
	size_t setResponseCode(size_t);

	// 添加默认头信息
	size_t addDefaultHeaderField();

	void addHeader(const std::string &name, const std::string &value);

	/*查找 值*/
	std::list<std::pair<std::string, std::string>>::iterator find(const std::string &name);

	// 整理输出
	bool formate();

	size_t read(char * buffer, size_t length);
	
	void reset();


private:
	unsigned int responseCode;

	// 输出缓冲
	MemoryOperator<char> memFile;

	std::list<std::pair<std::string, std::string>> httpHeader;

	/*获取相应头第一行*/
	std::string getFisrtLine();
	
	// 写入缓冲区
	size_t write(const std::string &);

};

